@extends('admin.layout.index')
@section('content')
	<div class="portlet box green">

							<div class="portlet-title">

								<div class="caption"><i class="icon-globe"></i><font><font>轮播图管理</font></font></div>

								<div class="tools">

									<a href="javascript:;" class="reload"></a>

									<a href="javascript:;" class="remove"></a>

								</div>

							</div>

							<div class="portlet-body">

								<div id="sample_1_wrapper" class="dataTables_wrapper form-inline" role="grid">
									<div class="row-fluid">
										<div class="span6">
											<div id="sample_1_length" class="dataTables_length"></div>
											
								
										</div>
										<div class="span6">
											<div class="dataTables_filter" id="sample_1_filter"></div>
										</div>
											<table class="table table-striped table-bordered table-hover table-full-width dataTable" id="sample_1" aria-describedby="sample_1_info">

									<thead>
										<div class="clearfix">

											<div class="btn-group">

												<button id="sample_editable_1_new" class="btn green" onClick="location.href='/admin/slide/create'">

												添加轮播图 <i class="icon-plus"></i>

												</button>

											</div>
                            			 
										</div>

										<tr role="row">
											<th class="tc" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 31px;"><font><font>排序</font></font></th>
											<th class="tc" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 31px;"><font><font>ID</font></font></th>
											<th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 197px;">
											<font><font>缩略图</font></font></th>
											<th class="sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 268px;">
											<font><font>描述</font></font></th>
											<th class="sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 268px;">
											<font><font>Url</font></font></th>
											<th class="sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 268px;">
											<font><font>操作</font></font></th>
											
											
											
											
										</tr>
										@foreach($data as $k=>$v) 
										<tr>
											<td class="tc">
                            					<input type="text" name="order" value="{{$v['order']}}" onchange="changeOrder(this,{{$v->id}})" style="width:30px;" >
                        					</td>
											<td class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 31px;"><font><font>{{$v['id']}}</font></font></td>
											<td class="sorting_asc" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" >
											<img src="/{{ $v['pic'] }}" alt="" style="width:150px;height:150px;"></td>
											<td class="sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 268px;">
											<font><font>{{$v['description']}}</font></font></td>
											<td class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 246px;">
											<font><font>{{$v['url']}}</font></font></td>
											
											<td class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 246px;">
											<form method="post" action="/admin/slide/{{$v['id']}}">
					                    		{{csrf_field()}}
					                    		<input type="hidden" value="DELETE" name="_method">
					                    		<button type="button" class="btn blue" onclick="delslide({{$v['id']}})"><i class="icon-trash"></i>删除</button>
					                    		
					                    	</form>
	
											</td>
											
										</tr>
										@endforeach
									</thead>
									<script>
									</script>

		
									

					</table>
					
					
					
					<div class="dataTables_paginate paging_bootstrap pagination" style="float:right;">
						{!! $data->appends($request)->render()!!}
					</div>
					
					
		<script>

			      // 参数1  当前文本框 参数 要修改记录的ID
        function changeOrder(obj,id){
        
//            获取文本框的值
           var order =  $(obj).val();
//            向服务器发送ajax请求，修改当前记录的order字段的值
            $.post('{{url('admin/slide/changeorder')}}',{'_token':'{{csrf_token()}}','id':id,'order':order},function(data){
                // alert(data);
//                    修改成功
				// console.log(msg)
                if(data.status == 0){
                    layer.msg(data.msg, {icon: 6});
                    location.href = location.href;
                }else{
                    layer.msg(data.msg, {icon: 5});
                    location.href = location.href;
                }
            });
        }



			// 删除 弹框
			function delslide(id){


            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('admin/slide')}}/'+id,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
//                    删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            }, function(){

            });




        }


		</script>

@endsection